namespace CSharpPro._0928;

public class Demo1
{
    public void work1(int n)
    {
        Console.WriteLine(n+"以内的水仙花数有：");

        int time = 1;
        for (int num = 1; num < n; num++)
        {
            if (num >= Math.Pow(10, time))
            {
                ++time;
            }
            istrue(num, time);
        }
    }

    private void istrue(int number, int time)
    {
        int sum = 0;
        int number2 = number;
        while (number2 > 0)
        {
            int team = number2 % 10;
            number2 /= 10;
            sum += (int)Math.Pow(team, time);
        }

        if (number == sum)
        {
            Console.WriteLine(number);
        }
    }
}